package me.yuzho.study.concurrency;

/** 创建代价昂贵的对象
 * @author yzhou-citrix
 *
 */
public class Fat {

    private volatile double d; //prevent optimization
    private static int counter = 0;
    private final int id = counter++;
    
    public Fat() {
        // Expensive, interruptible operation
        for(int i=1; i< 10000; i++) {
            d += (Math.PI + Math.E) /(double) i;
        }
    }
    
    public void operation() { System.out.println(this); }
    @Override
    public String toString() {
        return "Fat id: " + id + "," + d;
    }
}
